Skip to content

refactor(api): migrate functions.invoke to Cloudflare API - #2785

Open
riderx wants to merge 14 commits into
mainfrom
chore/migrate-invoke-to-cloudflare
Open

refactor(api): migrate functions.invoke to Cloudflare API#2785
riderx wants to merge 14 commits into
mainfrom
chore/migrate-invoke-to-cloudflare

Conversation

@riderx

@riderx riderx commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary (AI generated)

  • Route Capgo console supabase.functions.invoke calls through invokeCapgoApiVITE_API_HOST (api.capgo.app) instead of sb.capgo.app
  • Route Capgo CLI former invoke call sites through invokeCapgoCliApihostApi / hostFilesApi (self-host still uses /functions/v1)
  • Shrink Capgo cloud Supabase publish allowlist: keep triggers forever; keep bundle, channel, files, private until 2026-10-28 for older CLIs; stop publishing console-only apikey, app, organization, statistics, webhooks

Motivation (AI generated)

Publishing unused Capgo cloud edge functions is an infra abuse risk. Console and new CLI can talk to Cloudflare directly; old CLIs still hit Supabase invoke for a few endpoints, so those stay published for ~3 months.

Business Impact (AI generated)

Fewer Capgo cloud Supabase functions to operate and attack, without breaking existing customer CLIs during the upgrade window. Self-host full deploy is unchanged.

Test Plan (AI generated)

  • Console: open API keys, webhooks, Stripe portal/checkout, org invites, password compliance — confirm requests go to api.capgo.app, not sb.capgo.app/functions/v1
  • CLI latest: bundle upload, channel set/delete, upload link / delete failed version / set manifest against Capgo cloud
  • CLI with --supa-host / self-host: same flows still hit /functions/v1
  • Capgo cloud deploy only publishes allowlisted functions (bun scripts/supabase-cloud-functions.ts list)
  • Unit: bunx vitest run tests/supabase-cloud-functions.unit.test.ts
  • After 2026-10-28: remove bundle/channel/files/private from the allowlist and delete Capgo cloud Supabase deployments

Generated with AI

Made with Cursor

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added unified API routing for cloud, self-hosted, and local deployments.
    • Improved support for configurable deployment hosts and authentication.
    • Standardized responses and error handling across dashboard, onboarding, billing, webhooks, access control, and account features.
  • Deployment

    • Cloud deployments now publish only approved functions and remove obsolete ones.
    • Added safeguards when no deployable functions are available.
  • Documentation

    • Clarified cloud and self-hosted deployment behavior, routing, and migration timelines.
  • Tests

    • Added coverage for deployment allowlists and API integration updates.

riderx and others added 4 commits July 28, 2026 18:44
Capgo cloud traffic already runs on Cloudflare Workers; only `triggers`
must stay on Supabase for pg_net queue_consumer. Keep full deploy for
self-hosting.

Co-authored-by: Cursor <cursoragent@cursor.com>
Address review feedback: show allowlisted Capgo Cloud deploy commands and
cover empty/multi-target allowlist deploy arg cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
supabase.functions.invoke always uses SUPABASE_URL, so console/CLI still
need private, apikey, app, bundle, channel, files, organization,
statistics, and webhooks published alongside triggers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Stop Capgo cloud console traffic on sb.capgo.app edge functions by calling
api.capgo.app instead. Migrate CLI the same way while keeping
bundle/channel/files/private published until 2026-10-28 for older CLIs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds allowlisted Supabase function deployment with cleanup, introduces cloud/self-hosted Capgo API routing for the CLI, and migrates frontend Supabase Edge Function calls to shared Capgo API services with updated tests and Cloudflare worker routes.

Changes

Capgo API and deployment routing

Layer / File(s) Summary
Allowlisted Supabase function publishing and deployment
scripts/supabase-cloud-functions.ts, .github/workflows/build_and_deploy.yml, package.json, README.md, tests/supabase-cloud-functions.unit.test.ts
Cloud deployments select allowlisted functions only, abort on empty selections, delete non-allowlisted functions, and document distinct cloud and self-hosted paths. Legacy CLI functions deprecate through 2026-10-28.
CLI API routing and authentication infrastructure
cli/src/utils.ts
CLI detects Capgo-managed Supabase hosts, resolves cloud or self-hosted endpoints, caches remote configuration with request deduplication, and provides authenticated invocation with structured error handling and response parsing.
CLI upload, channel, and rollout operations
cli/src/bundle/upload.ts, cli/src/channel/delete.ts, cli/src/channel/set.ts
Bundle upload, channel promotion, channel creation, rollout updates, manifest persistence, and failed-version cleanup forward API keys and optional Supabase connection settings to invokeCapgoCliApi.
Frontend Capgo API service and error handling
src/services/capgoApi.ts, tests/capgo-api-error-code.unit.test.ts
Frontend provides invokeCapgoApi to route requests to Capgo cloud or Supabase functions, handles session and anonymous authorization, serializes request bodies, parses responses, and extracts error codes including PostgreSQL unique-violation mappings to 23505.
Frontend services and components API migration
src/services/*, src/components/*, src/pages/*, src/stores/*, src/utils/*, cloudflare_workers/api/index.ts, tests/*
Frontend services (API keys, chart data, email OTP, Stripe, webhooks, statistics) and components (dashboard, onboarding, account, organization, access control, devices, invitations) replace direct Supabase function calls with invokeCapgoApi or service wrappers. Request payloads, HTTP methods, response handling, and error flows remain unchanged. Tests mock the new API boundary. Cloudflare worker routes register /role_bindings and /website_preview endpoints.

Estimated code review effort: 4 (Complex) | ~75 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Frontend or CLI
  participant invokeCapgoApi
  participant CapgoCloud or Supabase
  Frontend or CLI->>invokeCapgoApi: send path, method, body, credentials
  invokeCapgoApi->>CapgoCloud or Supabase: route to cloud or self-hosted endpoint
  CapgoCloud or Supabase-->>invokeCapgoApi: return response or error
  invokeCapgoApi->>invokeCapgoApi: parse response, extract error code
  invokeCapgoApi-->>Frontend or CLI: return standardized {data, error}
Loading

Possibly related PRs

  • Cap-go/capgo.app#2781: The main PR extends PR #2781's Supabase function allowlisting with deprecation, deletion, and validation behavior.
  • Cap-go/capgo.app#2737: Shares CLI API-host resolution and self-hosted routing utilities in cli/src/utils.ts.

Suggested labels: codex

Suggested reviewers: dalanir, wcaleniewolny

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.79% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: migrating Supabase function invocations to the Cloudflare API.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Repository analysis: Couldn't refresh Cap-go/capgo.app clone - clone failed: Clone operation failed: Stream initialization permanently failed: 14 UNAVAILABLE: read ECONNRESET


Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing chore/migrate-invoke-to-cloudflare (765679a) with main (3d4f65d)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Default invoke helpers to any like supabase.functions.invoke and tighten
the few call sites that still need explicit shapes for typecheck.

Co-authored-by: Cursor <cursoragent@cursor.com>
log-as and apikeys unit tests still stubbed supabase.functions.invoke after
the Cloudflare helper migration; point them at invokeCapgoApi instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
@riderx
riderx marked this pull request as ready for review July 29, 2026 00:03
@riderx

riderx commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_5b4e8f49-4017-49fb-8cfc-975b08519925)

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 39 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/services/capgoApi.ts Outdated
Comment thread src/services/chartDataService.ts
Comment thread src/components/tables/AccessTable.vue
Comment thread src/pages/invitation.vue
Comment thread scripts/supabase-cloud-functions.ts
Comment thread cli/src/channel/delete.ts
Comment thread cli/src/utils.ts Outdated
Comment thread cli/src/channel/set.ts
Comment thread src/pages/settings/account/ManageTwoFactor.vue Outdated
Comment thread tests/apikeys-service.unit.test.ts
Keep unread error bodies for FunctionsHttpError, support anonymous invite
bootstrap, fall back to /functions/v1 for self-host consoles, fix CLI auth
and Capgo-managed --supa-host routing, and make Capgo cloud deploy fail
closed plus delete non-allowlisted functions.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/services/capgoApi.ts
Comment thread src/components/dashboard/Usage.vue Outdated
@cursor
cursor Bot requested review from Dalanir and WcaleNieWolny July 30, 2026 23:34

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed as skipped, so it is not a clean approval signal, and this PR changes console/CLI API routing plus Capgo cloud function publish allowlists (auth, billing, and deploy surface). Assigning reviewers for human review; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped due to usage limit), and this PR is above the low-risk approval threshold given broad console/CLI API routing and deploy-surface changes. Assigned reviewers for human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pages/app/[app].channel.[channel].devices.vue (1)

119-176: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Route setChannelDeviceOverride through invokeCapgoApi.

Self-host/local consoles route API calls through Supabase /functions/v1, but this flow still posts channel_device directly to VITE_API_HOST, bypassing that fallback and potentially sending the override request to Capgo Cloud. Migrate this call to invokeCapgoApi and handle its returned error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/app/`[app].channel.[channel].devices.vue around lines 119 - 176,
Update setChannelDeviceOverride to call invokeCapgoApi for
private/channel_device instead of fetch against defaultApiHost, preserving the
existing app, channel, and device request fields. Handle the returned error in
customDeviceOverwritePart5 through the existing overwrite-error path, and remove
the direct session/JWT and HTTP response handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/src/utils.ts`:
- Around line 792-862: Update invokeCapgoCliApi to reuse the result of
getRemoteConfig(true) across calls during the CLI process, while preserving
explicit supaHost/supaAnon behavior and avoiding stale configuration beyond that
process. Review the non-functions/v1 Authorization construction in
invokeCapgoCliApi against the Cloudflare API contract; use the required Bearer
format if the API validates Authorization, otherwise retain raw-key behavior
only when capgkey is intentionally the sole credential and ensure the
implementation reflects that contract.
- Around line 748-757: Validate the --supa-host value centrally before routing
or invoking the API, using isCapgoManagedSupabaseHost and the existing
host-normalization flow where appropriate. Reject malformed or unsupported hosts
with a clear CLI-facing error that states the required URL format, and ensure
this validation occurs inside invokeCapgoCliApi()’s error-handling path so raw
“Invalid URL” TypeErrors do not escape.

In `@package.json`:
- Around line 187-188: Make Supabase stale-function cleanup fail closed: in
package.json lines 187-188, remove unconditional success masking from
deploy:supabase:prod and deploy:supabase:preprod, ignoring deletion errors only
when the function is confirmed missing; in
.github/workflows/build_and_deploy.yml lines 97-109, ensure cleanup failures
propagate and fail the workflow rather than being masked; in README.md lines
467-470, document the full cleanup-aware deployment procedure or explicitly
state that the alternate command does not remove stale functions.

In `@README.md`:
- Around line 80-83: Correct the console/CLI routing description in the README
paragraph: limit SUPABASE_URL routing to self-hosted deployments and legacy CLI
compatibility through October 28, 2026. State that the migrated Capgo Cloud
console uses VITE_API_HOST and the new CLI uses Capgo API hosts, while
preserving the existing Supabase function and pg_net context.

In `@src/components/dashboard/AppOnboardingFlow.vue`:
- Around line 644-648: Update the organization-creation error handling in the
unified onboarding flow around the `if (error || !data?.id)` block to read the
duplicate-name code from the HTTP error body by parsing the `FunctionsHttpError`
response in `error.context` before checking for `23505`. Use the parsed body
code for the `org-with-this-name-exists` toast, while preserving the generic
`cannot-create-org` fallback.

In `@src/services/apikeys.ts`:
- Line 68: Update each invokeCapgoApi call in src/services/apikeys.ts:68-68 and
124-124, src/services/chartDataService.ts:39-39, src/utils/invites.ts:44-44, and
src/utils/onboardingAppCreateHelpers.ts:124-124 to pass the caller-supplied
Supabase client/context, preserving injected client, session, and configuration
behavior instead of resolving the global client.

In `@src/services/capgoApi.ts`:
- Line 4: Update the method type declaration to use the repository’s accepted
single-quote style for all HTTP method literals, without changing the allowed
values or optional property behavior.

In `@src/services/emailOtp.ts`:
- Around line 52-54: Update the invokeCapgoApi call in the email OTP
verification flow to pass allowAnonymous: true, preserving unauthenticated
access while keeping the existing token sanitization and
private/verify_email_otp endpoint unchanged.

In `@tests/apikeys-service.unit.test.ts`:
- Around line 32-40: Remove the concurrent modifier from the “creates a member
key with only the selected app bindings” test so it runs as a standard
sequential test, preserving the shared hoisted mocks and beforeEach resets.

In `@tests/supabase-cloud-functions.unit.test.ts`:
- Around line 39-41: Extend the existing buildCapgoCloudSupabaseDeployArgs test
coverage to assert that passing an empty array throws, preserving the
fail-closed guard while retaining the explicit-list expectation.

---

Outside diff comments:
In `@src/pages/app/`[app].channel.[channel].devices.vue:
- Around line 119-176: Update setChannelDeviceOverride to call invokeCapgoApi
for private/channel_device instead of fetch against defaultApiHost, preserving
the existing app, channel, and device request fields. Handle the returned error
in customDeviceOverwritePart5 through the existing overwrite-error path, and
remove the direct session/JWT and HTTP response handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 24a10173-2a16-4ac1-8f48-d066b11fe8a1

📥 Commits

Reviewing files that changed from the base of the PR and between 622efa9 and a3c0cae.

📒 Files selected for processing (39)
  • .github/workflows/build_and_deploy.yml
  • README.md
  • cli/src/bundle/upload.ts
  • cli/src/channel/delete.ts
  • cli/src/channel/set.ts
  • cli/src/utils.ts
  • package.json
  • scripts/supabase-cloud-functions.ts
  • src/components/dashboard/AppAccess.vue
  • src/components/dashboard/AppOnboardingFlow.vue
  • src/components/dashboard/AppSetting.vue
  • src/components/dashboard/InviteTeammateModal.vue
  • src/components/dashboard/StepsApp.vue
  • src/components/dashboard/Usage.vue
  • src/components/permissions/ChannelAccessPanel.vue
  • src/components/tables/AccessTable.vue
  • src/pages/ApiKeys.vue
  • src/pages/app/[app].channel.[channel].devices.vue
  • src/pages/invitation.vue
  • src/pages/onboarding/organization.vue
  • src/pages/settings/account/ChangePassword.vue
  • src/pages/settings/account/ManageTwoFactor.vue
  • src/pages/settings/organization/Members.vue
  • src/pages/settings/organization/Plans.vue
  • src/pages/settings/organization/Security.vue
  • src/pages/settings/organization/index.vue
  • src/services/apikeys.ts
  • src/services/capgoApi.ts
  • src/services/chartDataService.ts
  • src/services/emailOtp.ts
  • src/services/logAs.ts
  • src/services/stripe.ts
  • src/services/supabase.ts
  • src/stores/webhooks.ts
  • src/utils/invites.ts
  • src/utils/onboardingAppCreateHelpers.ts
  • tests/apikeys-service.unit.test.ts
  • tests/log-as-service.unit.test.ts
  • tests/supabase-cloud-functions.unit.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

Comment thread cli/src/utils.ts Outdated
Comment thread cli/src/utils.ts
Comment thread package.json Outdated
Comment thread README.md Outdated
Comment thread src/components/dashboard/AppOnboardingFlow.vue
Comment thread src/services/apikeys.ts
Comment thread src/services/capgoApi.ts Outdated
Comment thread src/services/emailOtp.ts
Comment thread tests/apikeys-service.unit.test.ts
Comment thread tests/supabase-cloud-functions.unit.test.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed as skipped on this sync, and this PR exceeds the low-risk approval threshold (console/CLI API routing plus Capgo cloud deploy allowlist changes). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot did not complete successfully on this commit (skipped/neutral), and unresolved Bugbot findings remain on this broad console/CLI API-routing and deploy-surface change. Reviewers are already assigned; no additional reviewers added.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

Comment thread cli/src/utils.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot did not complete successfully (skipped) and still has an unresolved finding on this broad console/CLI API-routing and Capgo cloud deploy-surface change. Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed as skipped/neutral with an unresolved finding, and this PR exceeds the low-risk approval threshold (console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 13 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread cli/src/utils.ts Outdated
Comment thread src/services/emailOtp.ts Outdated
Only cache successful /private/config responses so transient failures can
recover, and stop sending anon JWT to verify_email_otp which rejects it.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed successfully with no open findings, but this PR exceeds the medium approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed successfully with no open findings, but this PR exceeds the low-risk approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/components/dashboard/AppOnboardingFlow.vue

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed as skipped on this sync and still has an unresolved finding, and this PR exceeds the low-risk approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed as skipped/neutral with an unresolved finding, and this PR exceeds the medium approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 27bfda5. Configure here.

Comment thread src/utils/invites.ts
Comment thread cli/src/utils.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed as skipped on this sync and still has unresolved findings, and this PR exceeds the low-risk approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: high. Left a non-blocking comment — Cursor Bugbot completed as skipped/neutral with 2 unresolved findings, and this PR exceeds the medium approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: high. Left a non-blocking comment — Cursor Bugbot completed successfully with no open findings, but this PR exceeds the medium approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: high. Left a non-blocking comment — Cursor Bugbot completed successfully with no open findings, but this PR exceeds the low-risk approval threshold (broad console/CLI API routing plus Capgo cloud deploy allowlist). Reviewers are already assigned; no approval from this run.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver External

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_f58a5981-fb7f-436a-babb-c229cc4d8299)

@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cli/src/utils.ts (1)

993-1002: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fall back when the action RPC is unavailable for any caller.

When appId is omitted, Line 995 calls is_allowed_action_org_action without an app ID. If an older self-hosted server lacks that RPC, PostgREST returns PGRST202. Line 1000 does not handle that path, so checkPlanValidUpload(supabase, orgId) fails instead of using the stable isAllowedActionOrg RPC.

Apply the PGRST202 fallback regardless of appId. Add coverage for both app-scoped and org-scoped calls.

Proposed fix
-    if (appId && error.code === 'PGRST202')
+    if (error.code === 'PGRST202')
       return isAllowedActionOrg(supabase, orgId)

As per coding guidelines, “Public API and plugin changes must remain backward compatible: do not remove or change existing fields, meanings, formats, or status codes.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/utils.ts` around lines 993 - 1002, Update the error handling around
the is_allowed_action_org_action RPC in the relevant utility so any PGRST202
error, with or without appId, falls back to isAllowedActionOrg(supabase, orgId).
Preserve throwing formatted errors for all other failures, and add coverage for
both app-scoped and org-scoped calls.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/supabase-cloud-functions.unit.test.ts`:
- Around line 13-60: Run the independent test cases in this suite concurrently
by replacing each applicable `it` declaration with `it.concurrent`. Apply this
to the tests covering function lists, deploy arguments, empty selections, and
skipped local functions, without changing their assertions or shared behavior.

---

Outside diff comments:
In `@cli/src/utils.ts`:
- Around line 993-1002: Update the error handling around the
is_allowed_action_org_action RPC in the relevant utility so any PGRST202 error,
with or without appId, falls back to isAllowedActionOrg(supabase, orgId).
Preserve throwing formatted errors for all other failures, and add coverage for
both app-scoped and org-scoped calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5909b8b2-35e5-469c-9acd-16e34ea3ce0d

📥 Commits

Reviewing files that changed from the base of the PR and between a3c0cae and 765679a.

📒 Files selected for processing (23)
  • .github/workflows/build_and_deploy.yml
  • README.md
  • cli/src/bundle/upload.ts
  • cli/src/channel/set.ts
  • cli/src/utils.ts
  • cloudflare_workers/api/index.ts
  • package.json
  • scripts/supabase-cloud-functions.ts
  • src/components/dashboard/AppOnboardingFlow.vue
  • src/components/dashboard/Usage.vue
  • src/pages/ApiKeys.vue
  • src/pages/onboarding/organization.vue
  • src/pages/settings/account/ChangePassword.vue
  • src/services/apikeys.ts
  • src/services/capgoApi.ts
  • src/services/chartDataService.ts
  • src/services/emailOtp.ts
  • src/services/supabase.ts
  • src/utils/invites.ts
  • src/utils/onboardingAppCreateHelpers.ts
  • tests/apikeys-service.unit.test.ts
  • tests/capgo-api-error-code.unit.test.ts
  • tests/supabase-cloud-functions.unit.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

Comment on lines +13 to +60
it('keeps pg_net triggers forever and CLI-deprecated functions until sunset', () => {
expect([...CAPGO_CLOUD_SUPABASE_FUNCTIONS_FOREVER]).toEqual(['triggers'])
expect([...CAPGO_CLOUD_SUPABASE_FUNCTIONS_CLI_DEPRECATION]).toEqual([
'bundle',
'channel',
'files',
'private',
])
expect(CAPGO_CLOUD_SUPABASE_FUNCTIONS_CLI_DEPRECATION_UNTIL).toBe('2026-10-28')
expect([...CAPGO_CLOUD_SUPABASE_FUNCTIONS]).toEqual([
'triggers',
'bundle',
'channel',
'files',
'private',
])
expect(buildCapgoCloudSupabaseDeployArgs()).toEqual([...CAPGO_CLOUD_SUPABASE_FUNCTIONS])
})

it('no longer publishes console-only invoke targets on Capgo cloud Supabase', () => {
for (const name of ['apikey', 'app', 'organization', 'statistics', 'webhooks'] as const) {
expect(CAPGO_CLOUD_SUPABASE_FUNCTIONS).not.toContain(name)
expect(listCapgoCloudSkippedSupabaseFunctions()).toContain(name)
}
})

it('builds deploy args from an explicit list', () => {
expect(buildCapgoCloudSupabaseDeployArgs(['triggers', 'ok'])).toEqual(['triggers', 'ok'])
})

it('rejects an empty Capgo cloud deploy selection', () => {
expect(() => buildCapgoCloudSupabaseDeployArgs([])).toThrow('CAPGO_CLOUD_SUPABASE_FUNCTIONS must not be empty')
})

it('skips Capgo-cloud-only unused local functions while keeping allowlisted ones', () => {
const local = listLocalSupabaseFunctions()
expect(local).toContain('triggers')
expect(local).toContain('private')
expect(local).toContain('updates')

const skipped = listCapgoCloudSkippedSupabaseFunctions(local)
for (const keep of CAPGO_CLOUD_SUPABASE_FUNCTIONS)
expect(skipped).not.toContain(keep)
expect(skipped).toContain('updates')
expect(skipped).toContain('stats')
expect(skipped).toContain('ok')
expect(skipped.length).toBe(local.length - CAPGO_CLOUD_SUPABASE_FUNCTIONS.length)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Run independent test cases concurrently.

These test cases do not modify shared state. Replace it with it.concurrent.

As per coding guidelines, “Tests run in parallel across files; isolate all modified shared resources with dedicated uniquely named seed data, and use it.concurrent() when possible.” Based on learnings, the exception for shared mocks and global mutations does not apply here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/supabase-cloud-functions.unit.test.ts` around lines 13 - 60, Run the
independent test cases in this suite concurrently by replacing each applicable
`it` declaration with `it.concurrent`. Apply this to the tests covering function
lists, deploy arguments, empty selections, and skipped local functions, without
changing their assertions or shared behavior.

Sources: Coding guidelines, Learnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant